package com.shisan.tingshu.account.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shisan.tingshu.common.result.Result;
import com.shisan.tingshu.model.account.RechargeInfo;
import com.shisan.tingshu.model.account.UserAccount;
import com.baomidou.mybatisplus.extension.service.IService;
import com.shisan.tingshu.model.account.UserAccountDetail;
import com.shisan.tingshu.vo.account.AccountLockResultVo;
import com.shisan.tingshu.vo.account.AccountLockVo;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {

    /**
     * 查询用户余额
     * @param userId
     * @return
     */
    BigDecimal getAvailableAmount(Long userId);

    /**
     * 查询并锁定用户余额
     * @param accountLockVo
     * @return
     */
    Result<AccountLockResultVo> checkAndLockAmount(AccountLockVo accountLockVo);

    /**
     * 记录用户账户流水
     */
    void log(Long userId, BigDecimal amount, String content, String orderNo, String tradeType);

    /**
     * 根据订单号查询充值信息
     * @param orderNo
     * @param userId
     * @return
     */
    RechargeInfo getRechargeInfoByOrderNo(String orderNo, Long userId);

    /**
     * 查询用户的消费记录
     * @param page
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserConsumePage(IPage<UserAccountDetail> page, Long userId);

    /**
     * 查询用户的充值记录
     * @param page
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserRechargePage(IPage<UserAccountDetail> page, Long userId);
}
